/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import ads.graph.Graph;
import ads.graph.Graph.Node;
import ads.graph.GraphToolBox;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;

/**
 *
 * @author framet-lap
 */
public class DijkstraTest {

    private Graph graph;

    public DijkstraTest() {
    }

    @Before
    public void setUp() {
        try {
            graph = GraphToolBox.createGraphWithFile("C:\\Users\\framet-lap\\Documents\\Studium\\ADS\\Svn\\trunk\\Exbox\\src\\ads\\graph\\graphInputFile");
        } catch (FileNotFoundException ex) {
            Logger.getLogger(GraphTest.class.getName()).log(Level.SEVERE, null, ex);
            assertTrue(false);
        } catch (IOException ex) {
            Logger.getLogger(GraphTest.class.getName()).log(Level.SEVERE, null, ex);
            assertTrue(false);
        }
    }

    @Test
    public void dijkstraTest() {
        try {
            System.out.println("Weg von Winterthur nach Lugano");
            for (Node n : graph.getShortestWay("Winterthur", "Lugano")) {
                System.out.println(n.getLabel());
            }
            System.out.println("Weg von Winterthur nach Lugano ohne Luzern - Lugano");
            
            Node n1 = graph.getNode("Lugano");
            Node n2 = graph.getNode("Luzern");
            n1.removeEdge(n1.getEdgeTo(n2));
            n2.removeEdge(n2.getEdgeTo(n1));
            for (Node n : graph.getShortestWay("Winterthur", "Lugano")) {
                System.out.println(n.getLabel());
            }
        } catch (NoSuchElementException ex) {
            System.out.println("Elemente nicht gefunden");
        }
    }
}
